From: Marco Trevisan (TreviƱo) Date: Wed, 18 Oct 2017 10:32:22 +0000 (-0400) Subject: st-icon: Create shadow pipeline only at paint X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~929^2~5^2~29 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e522e2e804725ee67837fcb0ad7a9428baef40c3;p=gnome-shell.git st-icon: Create shadow pipeline only at paint Don't try to allocate the shadow after allocation, just do it at paint as it's done by other shadowed widgets --- diff --git a/src/st/st-icon.c b/src/st/st-icon.c index 988070cd7..5892f8a52 100644 --- a/src/st/st-icon.c +++ b/src/st/st-icon.c @@ -56,12 +56,15 @@ struct _StIconPrivate CoglPipeline *shadow_pipeline; StShadow *shadow_spec; + ClutterSize shadow_size; }; G_DEFINE_TYPE_WITH_PRIVATE (StIcon, st_icon, ST_TYPE_WIDGET) static void st_icon_update (StIcon *icon); static gboolean st_icon_update_icon_size (StIcon *icon); +static void st_icon_update_shadow_pipeline (StIcon *icon); +static void st_icon_clear_shadow_pipeline (StIcon *icon); #define DEFAULT_ICON_SIZE 48 @@ -158,12 +161,15 @@ st_icon_dispose (GObject *gobject) static void st_icon_paint (ClutterActor *actor) { - StIconPrivate *priv = ST_ICON (actor)->priv; + StIcon *icon = ST_ICON (actor); + StIconPrivate *priv = icon->priv; st_widget_paint_background (ST_WIDGET (actor)); if (priv->icon_texture) { + st_icon_update_shadow_pipeline (icon); + if (priv->shadow_pipeline) { ClutterActorBox allocation; @@ -186,7 +192,7 @@ st_icon_style_changed (StWidget *widget) StThemeNode *theme_node = st_widget_get_theme_node (widget); StIconPrivate *priv = self->priv; - g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref); + st_icon_clear_shadow_pipeline (self); g_clear_pointer (&priv->shadow_spec, st_shadow_unref); priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow"); @@ -265,21 +271,49 @@ st_icon_init (StIcon *self) } static void -st_icon_update_shadow_pipeline (StIcon *icon) +st_icon_clear_shadow_pipeline (StIcon *icon) { StIconPrivate *priv = icon->priv; g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref); + clutter_size_init (&priv->shadow_size, 0, 0); +} + +static void +st_icon_update_shadow_pipeline (StIcon *icon) +{ + StIconPrivate *priv = icon->priv; + + if (priv->icon_texture && priv->shadow_spec) + { + ClutterActorBox box; + float width, height; + + clutter_actor_get_allocation_box (CLUTTER_ACTOR (icon), &box); + clutter_actor_box_get_size (&box, &width, &height); + + if (priv->shadow_pipeline == NULL || + priv->shadow_size.width != width || + priv->shadow_size.height != height) + { + st_icon_clear_shadow_pipeline (icon); + + priv->shadow_pipeline = + _st_create_shadow_pipeline_from_actor (priv->shadow_spec, + priv->icon_texture); - if (priv->shadow_spec) - priv->shadow_pipeline = _st_create_shadow_pipeline_from_actor (priv->shadow_spec, priv->icon_texture); + if (priv->shadow_pipeline) + clutter_size_init (&priv->shadow_size, width, height); + } + } } static void on_pixbuf_changed (ClutterTexture *texture, StIcon *icon) { - st_icon_update_shadow_pipeline (icon); + st_icon_clear_shadow_pipeline (icon); + clutter_actor_queue_redraw (CLUTTER_ACTOR (icon)); } static void @@ -304,7 +338,7 @@ st_icon_finish_update (StIcon *icon) /* Remove the temporary ref we added */ g_object_unref (priv->icon_texture); - st_icon_update_shadow_pipeline (icon); + st_icon_clear_shadow_pipeline (icon); /* "pixbuf-change" is actually a misnomer for "texture-changed" */ g_signal_connect_object (priv->icon_texture, "pixbuf-change",